package com.doubao.notepad_blog_backend.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.doubao.notepad_blog_backend.common.api.ApiResult;
import com.doubao.notepad_blog_backend.domain.BmsBillboard;
import com.doubao.notepad_blog_backend.service.BmsBillboardService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/billboard")
@Api(value = "公告管理",tags = {"公告管理"})
public class BmsBillboardController extends BaseController {

    @Resource
    private BmsBillboardService bmsBillboardService;

    @GetMapping("/show")
    @ApiOperation( "所有公告" )
    public ApiResult<BmsBillboard> getNotices() {
        List<BmsBillboard> list =
                bmsBillboardService.list( new LambdaQueryWrapper<BmsBillboard>().eq( BmsBillboard::isShow, true ) );
        return ApiResult.success(list.get( list.size()-1 ));
    }


}
